/*
 * @Author: swc shanwenchao12138@163.com
 * @Date: 2024-08-23 10:43:12
 * @LastEditors: swc shanwenchao12138@163.com
 * @LastEditTime: 2025-09-08 19:44:35
 * @FilePath: \xf\src\components\base\modal\o-approval-info\command.ts
 * @Description:
 * @Version: 2.0
 * @Autor: swc
 */
import { Tsrv, ifs, ts } from '@/services';
import { N_cFlowchart } from '@/types';

class T_cmd {
  // 主组件箱
  private compBox: ifs.I_compBox;

  // 主组件ID
  private compID: string;

  // 主组件实例
  private self: any;
  // 主组refs

  private graph: N_cFlowchart.x6Graph;

  // 内部联络单明细 节点数据
  private approvalNodes: Array<any>;

  public regGraphEvents: Map<
    N_cFlowchart.EVENTS,
    (e: N_cFlowchart.I_eventParams) => void
  > = new Map();

  public nodesChanges: ifs.I_fv[][] = [];

  // 主组件created里初始化
  public init(self: any, compBoxInfo: ifs.I_compBoxInfo) {
    this.self = self;
    this.compBox = compBoxInfo.TcompBox;
    this.compID = compBoxInfo.compID;

    // 注册节点 点击事件
    this.regGraphEvents.set(
      N_cFlowchart.EVENTS.NODE_CLICK,
      this.graphNodeClick
    );
  }

  graphNodeClick = (e: N_cFlowchart.I_eventParams) => {
    this.self.nodeClick(e.cell.id);
    // const node = e.node;
    // const nodeProp = node.getProp();
    // const data = nodeProp.data;
    // if (nodeProp.shape === 'bpmn-begin' || nodeProp.shape === 'bpmn-end') {
    //   this.self.nodeClick(data.id);
    // }
  };

  public setGraph(graph: N_cFlowchart.x6Graph) {
    this.graph = graph;
  }

  public setApprovalNodes(approvalNodes: Array<any>) {
    this.approvalNodes = approvalNodes;
  }

  /**
   * @description: 添加内部联络单日志
   * @param {string} id: 内部联络单id
   * @param {number} type: 0-收到消息 1-查看内容 2-批注 3-确认 4-驳回
   * @param {string} info: 备注
   * @return {*}
   * @author: swc
   * @Date: 2024-09-04 19:29:50
   * @LastEditors: swc
   * @LastEditTime: Do not edit
   */
  public addLiaisonLog(type: number, info: string) {
    return Tsrv.addLiaisonLog(this.self.liaisonID, type, info);
  }

  // 获取下一级审批人
  public getNextApprover(): Promise<any> {
    return new Promise((resolve, reject) => {
      const approvalNodes = this.approvalNodes;
      const curApprover = this.self.curApprover;
      const currentSn = curApprover.sn;
      // 判断 当前节点是否是 用户组节点
      const curNodeUpdateData = [];
      curNodeUpdateData.push(
        new ts.T_fv()
          .setField(Tsrv.globalVar.fieldName.ID)
          .setValue(curApprover.id),
        new ts.T_fv().setField('confirm').setValue(1)
      );
      if (curApprover?.f_type === 2) {
        // const curUserInfo = {
        //   userID: Tsrv.getUserID(),
        //   userNO: Tsrv.getUserNo(),
        //   userName: Tsrv.getUserName()
        // };
        // curNodeUpdateData.push(
        //   new ts.T_fv()
        //     .setField('approver')
        //     .setValue(JSON.stringify([curUserInfo]))
        // );
      }
      // 根据规则————审批人只能有一个子节点，所以直接取第一个
      const nextNodeInfo = curApprover.son_data[0];
      if (Tsrv.noValue(nextNodeInfo)) {
        resolve([true, [curNodeUpdateData], []]);
        return;
      }
      const next = approvalNodes.find(
        item => item.f_code === nextNodeInfo.nodeCode
      );
      const nextNode = {
        id: next?.id,
        type: next.f_type,
        nodeID: next.f_code,
        confirm: next.confirm,
        order: next.sn,
        nodeData: next.graph_data ?? {},
        previousNodes: next.father_data ?? [],
        subsequentNodes: next.son_data ?? []
      };
      if (nextNode.type === 0) {
        // 审核人
        const nextNodeUpdata = [
          new ts.T_fv()
            .setField(Tsrv.globalVar.fieldName.ID)
            .setValue(nextNode.id),
          new ts.T_fv().setField('sn').setValue(currentSn + 1)
        ];
        const nextUsers = [
          {
            userID: '',
            userNO: nextNode.nodeData?.checker?.value ?? '',
            userName: nextNode.nodeData?.checker?.label ?? ''
          }
        ];
        resolve([false, [curNodeUpdateData, nextNodeUpdata], nextUsers]);
      } else if (nextNode.type === 1) {
        // 审批条件
        const selectedUsers = this.self.selectedUsers;
        // 审批条件传参
        const conditionParams = {
          id: nextNode.id,
          nodeID: nextNode.nodeID,
          funName: this.self.approvalTableName,
          liasionID: this.self.liaisonID,
          graphID: this.self.graphData.id,
          previousNodes: nextNode.previousNodes,
          subsequentNodes: nextNode.subsequentNodes,
          designatedApprovers: selectedUsers,
          operateInfo: {
            id: curApprover?.id ?? '',
            approver: {
              userID: Tsrv.getUserID(),
              userNO: Tsrv.getUserNo(),
              userName: Tsrv.getUserName()
            }
          }
        };
        this.getApproverByCond(
          nextNode?.nodeData?.condition?.value,
          conditionParams
          // params
        ).then(r => {
          const [b, p] = r;
          if (b) {
            try {
              const nextNodesUpdata = [];
              const nextUsers = [];
              // 1、条件节点要修改的数据
              const condNodeUpdata = [
                new ts.T_fv()
                  .setField(Tsrv.globalVar.fieldName.ID)
                  .setValue(nextNode.id),
                new ts.T_fv().setField('sn').setValue(currentSn + 1),
                new ts.T_fv().setField('confirm').setValue(1)
              ];
              nextNodesUpdata.push(condNodeUpdata);
              // 2、下一级节点要修改的数据
              for (let i = 0; i < p.length; i++) {
                const it = p[i];
                // 检查参数是否合规， 不合规抛出错误
                if (Tsrv.noValues(it?.id, it?.nodeID, it?.type)) {
                  throw new Error('nextApprovers传参不合法！');
                  // break;
                }
                // const n = approvalNodes.find(item => item.f_code === it.nodeID);
                const n = approvalNodes.find(item => item.id === it.id);
                if (!Tsrv.noValue(n)) {
                  const nextNodeUpdata = [
                    new ts.T_fv()
                      .setField(Tsrv.globalVar.fieldName.ID)
                      .setValue(n.id),
                    new ts.T_fv().setField('sn').setValue(currentSn + 2)
                  ];
                  if (n.f_type === 2 && !Tsrv.noValue(it?.approvers)) {
                    // const userIDs: Array<string> = it.approvers.map(
                    //   approver => approver?.userID
                    // );
                    const usersInfo: Array<string> = it.approvers.map(
                      approver => {
                        return {
                          userID: approver?.userID ?? '',
                          userNO: approver?.userNO ?? '',
                          userName: approver?.userName ?? ''
                        };
                      }
                    );
                    nextNodeUpdata.push(
                      new ts.T_fv()
                        .setField('approver')
                        // .setValue(userIDs.join(','))
                        .setValue(JSON.stringify(usersInfo))
                    );
                    // 收集具备审批权限的人员
                    it.approvers.forEach(el => {
                      if (!Tsrv.noValue(el?.userNO)) {
                        const person = {
                          userID: el?.userID ?? '',
                          userNO: el.userNO ?? '',
                          userName: el?.userName ?? ''
                        };
                        nextUsers.push(person);
                      }
                    });
                  } else {
                    const person = {
                      userID: '',
                      userNO: n.graph_data?.checker?.value ?? '',
                      userName: n.graph_data?.checker?.label ?? ''
                    };
                    nextUsers.push(person);
                  }
                  nextNodesUpdata.push(nextNodeUpdata);
                } else {
                  throw new Error('无该审批人节点数据');
                }
              }
              // 3、当前将要审核通过的node数据,,,
              nextNodesUpdata.push(curNodeUpdateData);
              if (!Tsrv.noValue(nextNodesUpdata)) {
                resolve([false, nextNodesUpdata, nextUsers]);
              }
            } catch (error) {
              console.error(error);
            }
          }
        });
      } else if (nextNode.type === 2) {
        // 用户组
        const nextUsers = [];
        const selectedUsers = this.self.selectedUsers;
        const changes = [curNodeUpdateData];
        const selectedUsersInfo = [];
        // 收集具备审批权力的人，以便发送消息通知
        if (!Tsrv.noValue(selectedUsers)) {
          for (let i = 0; i < selectedUsers.length; i++) {
            const el = selectedUsers[i];
            if (el?.type === 0) {
              const person = {
                userID: '',
                userNO: el.data?.checker?.value ?? '',
                userName: el.data?.checker?.label ?? ''
              };
              nextUsers.push(person);
            } else if (el?.type === 2) {
              const approvers = el?.approvers;
              if (!Tsrv.noValue(approvers)) {
                for (let j = 0; j < approvers.length; j++) {
                  const ele = approvers[j];
                  const p = {
                    userID: ele?.userID ?? '',
                    userNO: ele?.userNO ?? '',
                    userName: ele?.userName ?? ''
                  };
                  nextUsers.push(p);
                  if (!Tsrv.noValue(ele?.userID)) {
                    selectedUsersInfo.push(p);
                  }
                }
              }
            }
          }
        }
        // 下级审批节点需更新的数据
        const nextNodeUpdata = [
          new ts.T_fv()
            .setField(Tsrv.globalVar.fieldName.ID)
            .setValue(nextNode.id),
          new ts.T_fv().setField('sn').setValue(currentSn + 1),
          new ts.T_fv()
            .setField('approver')
            .setValue(JSON.stringify(selectedUsersInfo))
        ];
        changes.push(nextNodeUpdata);
        resolve([false, changes, nextUsers]);
      } else {
        reject(Tsrv.getI18nByValue('未能识别的节点类型'));
      }
    });
  }

  // 获取上一级审批人信息
  public getPrevApprover(baseNode: any, params: any = []): any {
    const approvalNodes = this.approvalNodes;
    const curApprover = baseNode;
    const prevNodesInfo = curApprover.previousNodes;
    if (prevNodesInfo.length === 0) {
      if (params.length === 0) {
        return [true, []];
      }
      return [false, params];
    }
    const prevNodes = [];
    for (let i = 0; i < prevNodesInfo.length; i++) {
      const ele = prevNodesInfo[i];
      const appointNode = approvalNodes.find(
        item => item.f_code === ele.nodeCode
      );
      if (!Tsrv.noValue(appointNode)) {
        // prevNodes.push(appointNode);
        prevNodes.push({
          id: appointNode.id,
          type: appointNode.f_type,
          nodeID: appointNode.f_code,
          confirm: appointNode.confirm,
          order: appointNode.sn,
          approvers: appointNode.approver ?? [],
          nodeData: appointNode.graph_data ?? null,
          previousNodes: appointNode.father_data ?? [],
          subsequentNodes: appointNode.son_data ?? []
        });
      }
    }
    const prevNode = prevNodes.find(item => item.confirm === 1);
    if (prevNode.type === 0 || prevNode.type === 2) {
      // 审核人
      params.push(prevNode);
      return [false, params];
    }
    if (prevNode.type === 1) {
      // 条件
      params.push(prevNode);
      return this.getPrevApprover(prevNode, params);
    }
    return [true, []];
  }

  /**
   * 获取审批人信息 通过条件
   * @param condition 获取审批人信息的条件
   * @param params
   */
  public getApproverByCond(condition: string, params: any): Promise<any> {
    return new Promise((resolve, reject) => {
      if (!Tsrv.noValue(condition)) {
        Tsrv.doEvent(
          condition,
          Tsrv.getFunInfo(this.self.approvalTableName) as ifs.I_funInfo,
          () => params
        )
          .then(r => {
            if (r.isErr()) {
              this.self.$msg(r.errmsg);
              resolve(false);
            } else {
              const res = r.getReturnData('conf');
              const data = res.res.data.request;
              if (Tsrv.noValues(data, data?.nextApprovers)) {
                // if (Tsrv.noValues(data, data?.nextApprover)) {
                this.self.$msg(Tsrv.getI18nByValue('没有获取到下一级审批人'));
                return;
              }
              resolve([true, data.nextApprovers]);
              // resolve([true, data.nextApprover]);
            }
          })
          .catch(err => {
            console.error(err);
            reject(false);
          });
      }
    });
  }

  /**
   * 修改刚审核节点的审批状态 和 下一级的 序号
   * @param nextNodes
   * @param status
   * @returns
   */
  public updateApprNodesStatus(
    nextNodes: Array<any>,
    status: number = 1
  ): Promise<boolean> {
    return new Promise((resolve, reject) => {
      // 条件节点、审批人节点的 审批状态和序号
      const approvers = nextNodes.filter(item => item.type === 0);
      const approvalCondition = nextNodes.filter(item => item.type === 1);
      const currentSn = this.self.curApprover.sn;
      const ctd = new ts.T_ctdArg();
      ctd
        .setTableName(Tsrv.globalVar.tableName.SYS_INTERNAL_LIAISON_SHEET_DET)
        .setDbType(Tsrv.globalVar.dbType.MYSQL);
      ctd.setRule({} as ifs.I_rule);
      const ctdUpdDatas: ifs.I_ctdUpdData[] = [];
      // 修改当前节点的审批状态
      const curUpdData = new ts.T_ctdUpdData();
      curUpdData.setDataRule({} as ifs.I_rule).setFileInfo({});
      const curData: ifs.I_fv[] = [];

      const curFilter = { id: this.self.curApprover.id };
      if (status) {
        curData.push(new ts.T_fv().setField('confirm').setValue(status));
      } else {
        curData.push(new ts.T_fv().setField('sn').setValue(0));
      }
      curUpdData.setFilter(curFilter);
      curUpdData.setRowData(...curData);
      ctdUpdDatas.push(curUpdData);
      // 当驳回时，同级的审批人节点，序号置为0
      const sameLevelNodes = this.approvalNodes.find(
        item => item.sn === currentSn
      );
      if (!status && !Tsrv.noValue(sameLevelNodes)) {
        const levelUpdData = new ts.T_ctdUpdData();
        levelUpdData.setDataRule({} as ifs.I_rule).setFileInfo({});
        const levelData: ifs.I_fv[] = [];

        const levelFilter = { id: sameLevelNodes.id };
        levelData.push(new ts.T_fv().setField('sn').setValue(0));
        levelUpdData.setFilter(levelFilter);
        levelUpdData.setRowData(...levelData);
        ctdUpdDatas.push(levelUpdData);
      }
      // 修改next节点的审批状态
      let filter: any = {};
      if (!Tsrv.noValue(nextNodes)) {
        nextNodes.forEach(ele => {
          const ctdUpdData = new ts.T_ctdUpdData();
          ctdUpdData.setDataRule({} as ifs.I_rule).setFileInfo({});
          const rowData: ifs.I_fv[] = [];

          filter = { id: ele.id };
          // rowData.push(new ts.T_fv().setField('confirm').setValue(status));
          if (approvalCondition.length > 0) {
            if (status) {
              ele.type === 0 &&
                rowData.push(
                  new ts.T_fv().setField('sn').setValue(currentSn + 2)
                );
              if (ele.type === 1) {
                rowData.push(
                  new ts.T_fv().setField('sn').setValue(currentSn + 1)
                );
                rowData.push(
                  new ts.T_fv().setField('confirm').setValue(status)
                );
              }
            } else {
              rowData.push(new ts.T_fv().setField('confirm').setValue(status));
              if (ele.type === 1) {
                rowData.push(new ts.T_fv().setField('sn').setValue(0));
              }
            }
          } else {
            if (status) {
              ele.type === 0 &&
                rowData.push(
                  new ts.T_fv().setField('sn').setValue(currentSn + 1)
                );
            } else {
              rowData.push(new ts.T_fv().setField('confirm').setValue(status));
            }
          }
          ctdUpdData.setFilter(filter);
          ctdUpdData.setRowData(...rowData);
          ctdUpdDatas.push(ctdUpdData);
        });
      }
      ctd.setUpdRecDataMany(...ctdUpdDatas);
      Tsrv.batRows(ctd).then(resp => {
        const [b, res, msg] = resp;
        msg && this.self.$msg(msg);
        if (b) {
          resolve(true);
        } else {
          reject();
        }
      });
    });
  }

  /**
   * 点击通过按钮后， 修改相应的节点数据
   * 当前节点、下一级节点（状态、序号、用户组的选中人员）
   * @param nextNodes
   * @param status
   * @returns
   */
  public updateApprovalNodesData(
    changes: Array<Array<ifs.I_fv>>
  ): Promise<boolean> {
    return new Promise((resolve, reject) => {
      // 条件节点、审批人节点的 审批状态和序号
      const ctd = new ts.T_ctdArg();
      ctd
        .setTableName(Tsrv.globalVar.tableName.SYS_INTERNAL_LIAISON_SHEET_DET)
        .setDbType(Tsrv.globalVar.dbType.MYSQL);
      ctd.setRule({} as ifs.I_rule);

      const ctdUpdDatas: ifs.I_ctdUpdData[] = [];

      for (let i = 0; i < changes.length; i++) {
        const change = changes[i];
        const nodeUpdData = new ts.T_ctdUpdData();
        nodeUpdData.setDataRule({} as ifs.I_rule).setFileInfo({});
        const nodeData: ifs.I_fv[] = [];

        const IDItem = change.find(
          el => el.field === Tsrv.globalVar.fieldName.ID
        );
        if (Tsrv.noValue(IDItem)) {
          continue;
        }

        const changeRows = change.filter(
          el => el.field !== Tsrv.globalVar.fieldName.ID
        );

        const nodeFilter = { id: IDItem.value };
        nodeData.push(...changeRows);
        nodeUpdData.setFilter(nodeFilter);
        nodeUpdData.setRowData(...nodeData);
        ctdUpdDatas.push(nodeUpdData);
      }

      ctd.setUpdRecDataMany(...ctdUpdDatas);
      Tsrv.batRows(ctd).then(resp => {
        const [b, res, msg] = resp;
        msg && this.self.$msg(msg);
        if (b) {
          resolve(true);
        } else {
          reject();
        }
      });
    });
  }

  public updateLiaisonStatus(status: number): Promise<boolean> {
    return new Promise((resolve, reject) => {
      const dbType = Tsrv.globalVar.dbType.MYSQL;
      const tableName = Tsrv.globalVar.tableName.SYS_INTERNAL_LIAISON_SHEET;
      const rule = {} as ifs.I_rule;
      const upd = new ts.T_ctdUpdRec();
      const filter = {
        id: this.self.liaisonID
      };
      const updData = [new ts.T_fv().setField('f_status').setValue(status)]; // 更新数据
      upd.setData({}, filter, {} as ifs.I_rule, ...updData);
      Tsrv.updRows(tableName, dbType, rule, upd).then(([ok, res, err]) => {
        if (!ok || !err) {
          this.self.$msg(err ?? res.msg);
          resolve(false);
        } else {
          this.self.$msg(res.msg);
          resolve(true);
        }
      });
    });
  }

  /**
   * 修改内审批的数据状态
   * @param status
   * @returns
   */
  public updateApproveStatus(
    funName: string,
    items: Array<string>,
    isPass: boolean = true
  ): Promise<boolean> {
    return new Promise((resolve, reject) => {
      if (Tsrv.noValue(items)) {
        resolve(false);
      }
      const upd = new ts.T_ctdUpdRec();
      const updDs: ts.T_ctdUpdData[] = [];
      const rule = new ts.T_rule();
      items.forEach(it => {
        const updD = new ts.T_ctdUpdData();
        updD.setFilter({ id: { $eq: it ?? '-1' } });
        const updataRecords: ifs.I_fv[] = [];
        updataRecords.push(
          ...[
            {
              field: '_status_',
              value: isPass ? 101 : 0
            } as ifs.I_fv,
            {
              field: '_audited_',
              value: isPass ? 1 : 0
            } as ifs.I_fv
          ]
        );
        updD.setRowData(...updataRecords);
        updDs.push(updD);
      });
      upd.setCtdUpdDatas(...updDs);

      Tsrv.updRows(funName, Tsrv.globalVar.dbType.MYSQL, rule, upd).then(
        ([ok, res, err]) => {
          if (!ok || !err) {
            this.self.$msg(err ?? res.msg);
            resolve(false);
          } else {
            this.self.$msg(res.msg);
            resolve(true);
          }
        }
      );
    });
  }

  /**
   * @description: 修改内部联络单状态 （0：审核中，1：已审核，9：已暂停，11：自作废）
   * @param {number} status
   * @return {*}
   * @author: swc
   * @Date: 2024-09-10 15:03:10
   * @LastEditors: zss
   * @LastEditTime: Do not edit
   */
  public liaisonAudit(status: number): Promise<boolean> {
    return new Promise((resolve, reject) => {
      const dbType = Tsrv.globalVar.dbType.MYSQL;
      const tableName = Tsrv.globalVar.tableName.SYS_INTERNAL_LIAISON_SHEET;
      const rule = {} as ifs.I_rule;
      const upd = new ts.T_ctdUpdRec();
      const filter = {
        id: this.self.liaisonID
      };
      const updData = [new ts.T_fv().setField('f_status').setValue(status)]; // 更新数据
      upd.setData({}, filter, {} as ifs.I_rule, ...updData);
      Tsrv.updRows(tableName, dbType, rule, upd)
        .then(([ok, res, err]) => {
          if (!ok || !err) {
            this.self.$msg(err ?? res.msg);
            resolve(false);
          } else {
            this.self.$msg(res.msg);
            resolve(true);
          }
        })
        .catch(er => {
          reject(er);
        });
    });
  }

  /**
   * 撤销审批
   * 1、内部联络单 数据 状态 变为 “已作废”
   *    11：已作废、9：已暂停:1：已审核:0：审核中
   * 2、被审核的数据 状态均变成 “未审核”， 打回原状态
   */
  public revokeApproval() {
    this.updateLiaisonStatus(11).then(res => {
      if (res) {
        const approvalTableName = this.self.approvalTableName;
        const originData = this.self.originData;
        if (!Tsrv.noValue(approvalTableName) && !Tsrv.noValue(originData)) {
          this.updateApproveStatus(approvalTableName, originData, false);
          this.self.hide();
        }
      }
    });
  }

  /**
   * @description: 发消息
   * const msg = new T_wsMsg();
   * msg.setToUserNo('dev03'); // "__ALLUSERS__"
   * msg.setToClientID(null);
   * msg.setCMD(0); // 0：消息、数据采集类、会谈
   * msg.setMsgType(0); // 0：广播、预警、警报、通知、待办事项、更新token
   * msg.setData('{"userNo":"dev03", "userPass":"123456", "dbName":"test"}');
   * @param {string} userNo 用户编号
   * @param {string} title 消息标题
   * @param {any} liaisonID 联络单ID
   * @return {*}
   * @author: swc
   * @Date: 2024-09-10 11:52:24
   * @LastEditors: zss
   * @LastEditTime: Do not edit
   */
  public sendMessage(userNo: string, title: string, liaisonID: string) {
    const msg = new ts.T_wsMsg();
    const msgBody = new ts.T_msgToDoList();
    msgBody
      .setCategory('approval')
      .setLiaisonID(liaisonID)
      .setTitle(title)
      .setContent(`${Tsrv.getI18nBySrv(title)}-审批`);
    msg
      .setToUserNo(userNo)
      .setToClientID(null)
      .setCMD(0)
      .setMsgType(4)
      .setData(msgBody);
    return Tsrv.sendMsg(msg);
  }

  /**
   * @description: 获取内部联络单的row数据
   * @return {*}
   * @author: swc
   * @Date: 2024-11-21 10:57:25
   * @LastEditors: swc
   * @LastEditTime: Do not edit
   */
  public getLiaison(): Promise<any> {
    const that = this.self;
    const dbType = Tsrv.globalVar.dbType.MYSQL;
    const tableName = Tsrv.globalVar.tableName.SYS_INTERNAL_LIAISON_SHEET;
    const gpd = new ts.T_getPartDataArg();
    gpd.setFunName(tableName).setLang(that.$i18n.locale || 'en-US');
    gpd.setPage(1, 99999).setDbType(dbType);
    gpd.setFilter({
      id: {
        $in: [that.liaisonID]
      }
    });
    return Tsrv.getData<any, ifs.I_getPartDataArg>(gpd);
  }

  /**
   * @description: 获取内部联络单明细数据
   * @description: （1、获取所有审批节点数据，2、找到当前审批人）
   * @return {*}
   * @author: swc
   * @Date: 2024-11-21 10:29:33
   * @LastEditors: swc
   * @LastEditTime: Do not edit
   */
  public getLiaisonDet(): Promise<any> {
    const that = this.self;
    const dbType = Tsrv.globalVar.dbType.MYSQL;
    const tableName = Tsrv.globalVar.tableName.SYS_INTERNAL_LIAISON_SHEET_DET;
    const gpd = new ts.T_getPartDataArg();
    gpd.setFunName(tableName).setLang(that.$i18n.locale || 'en-US');
    gpd.setPage(1, 99999).setDbType(dbType);
    gpd.setFilter({
      master_bill_id: { $in: [that.liaisonID] }
    });
    return Tsrv.getData<any, ifs.I_getPartDataArg>(gpd);
  }

  /**
   * @description: 获取用户组信息
   * @param {string} userGroupID
   * @return {*}
   */
  public getUserGruopInfo(userGroupID: string): Promise<any> {
    const that = this.self;
    const dbType = Tsrv.globalVar.dbType.MYSQL;
    const tableName = Tsrv.globalVar.tableName.SYS_USER_GROUP;
    const gpd = new ts.T_getPartDataArg();
    gpd.setFunName(tableName).setLang(that.$i18n.locale || 'en-US');
    gpd.setPage(1, 99999).setDbType(dbType);
    gpd.setFilter({
      master_bill_id: { $in: [userGroupID] }
    });
    return Tsrv.getData<any, ifs.I_getPartDataArg>(gpd);
  }

  public getTcmd(): T_cmd {
    return this;
  }
}
interface I_cmd extends T_cmd {}
export { I_cmd, T_cmd };
